package com.bysj.agent.service;


import bean.ChatMessage;

public class MessageService {
    // 使用ThreadLocal存储当前线程的token
    private static final ThreadLocal<ChatMessage> TOKEN_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置当前线程的chatMessage

     */
    public static void setMessage(ChatMessage chatMessage) {
        TOKEN_THREAD_LOCAL.set(chatMessage);
    }

    /**
     * 获取当前线程的chatMessage

     */
    public static ChatMessage getMessage() {
        return TOKEN_THREAD_LOCAL.get();
    }

    /**
     * 清除当前线程的chatMessage
     */
    public static void clearMessage() {
        TOKEN_THREAD_LOCAL.remove();
    }
}
